home *** CD-ROM | disk | FTP | other *** search
/ MacWarehouse Macintosh Games / MacWarehouse Macintosh Games.iso / AMBER demo / AMBER-Journeys Beyond™ Patch 1c / 00106_generic domain rules.ls < prev    next >
Encoding:
Text File  |  1997-02-19  |  13.5 KB  |  451 lines

  1. on cursorOff
  2.   global colorcrsr, YugoCursors, gCursorSwitch
  3.   if objectp(colorcrsr) then
  4.     colorcrsr(mGetSetCursor, getProp(YugoCursors, #noCursor))
  5.     set gCursorSwitch to #off
  6.   else
  7.     cursor(200)
  8.     set gCursorSwitch to #off
  9.   end if
  10. end
  11.  
  12. on cursorOn
  13.   global colorcrsr, YugoCursors, thisCursor, gCursorSwitch
  14.   if gCursorSwitch = #off then
  15.     if objectp(colorcrsr) then
  16.       colorcrsr(mGetSetCursor, getProp(YugoCursors, thisCursor))
  17.     else
  18.       castCursor(getProp(YugoCursors, thisCursor))
  19.     end if
  20.     set gCursorSwitch to #on
  21.   end if
  22. end
  23.  
  24. on setCursorQuality recommendation
  25.   global oPuppeteer
  26.   set the cursorQuality of oPuppeteer to recommendation
  27. end
  28.  
  29. on castCursor cursorID
  30.   set myCursorOffset to 2500
  31.   if integerp(cursorID) then
  32.     set whichCursor to cursorID - 6000
  33.   else
  34.     put "castCursor(): wow, a cursor label: "
  35.     put cursorID
  36.     exit
  37.   end if
  38.   set cMask to myCursorOffset + (whichCursor * 2)
  39.   cursor([cMask - 1, cMask])
  40. end
  41.  
  42. on killVideo
  43.   global lastScoreSprite
  44.   set vidSprite to 44
  45.   set the movieRate of sprite vidSprite to 0
  46.   set the locV of sprite vidSprite to -500
  47.   updateStage()
  48.   set the castNum of sprite vidSprite to 7
  49.   puppetSprite(vidSprite, 0)
  50. end
  51.  
  52. on pushVideo
  53.   set vidSprite to 44
  54.   set the movieTime of sprite 44 to 0
  55.   updateStage()
  56.   set the movieRate of sprite 44 to 1
  57.   repeat while the movieRate of sprite 44 <> 1
  58.     updateStage()
  59.   end repeat
  60. end
  61.  
  62. on setCurrentLocation suggestion
  63.   return "Use the goTo() function instead.."
  64. end
  65.  
  66. on goTo destination, transition
  67.   global oPuppeteer, oStoryteller, builderWindow, gPreloading, gScanFinish, colorcrsr, YugoCursors, thisCursor, gCursorSwitch, gPeekAlertEnabled
  68.   if objectp(colorcrsr) then
  69.     colorcrsr(mGetSetCursor, getProp(YugoCursors, #noCursor))
  70.   else
  71.     cursor(200)
  72.   end if
  73.   set gCursorSwitch to #off
  74.   if (destination = #destination) or (transition = #transition) then
  75.     exit
  76.   end if
  77.   setAt(getProp(the lsStateData of oStoryteller, #previousLocation), 1, getAt(getProp(the lsStateData of oStoryteller, #currentLocation), 1))
  78.   setAt(getProp(the lsStateData of oStoryteller, #currentLocation), 1, destination)
  79.   if the castNum of sprite 44 <> 7 then
  80.     killVideo()
  81.     moveMovies(oPuppeteer)
  82.   end if
  83.   if transition <> 0 then
  84.     setTransition(oPuppeteer, transition)
  85.   end if
  86.   moveToLocation(oPuppeteer)
  87.   if getPos(the windowList, builderWindow) then
  88.     tell builderWindow
  89.       refreshCast()
  90.       refreshHotspots()
  91.     end tell
  92.   end if
  93.   if gPreloading = 1 then
  94.     preloadLocations()
  95.   else
  96.   end if
  97.   set lsMoveCounter to getProp(the lsStateData of oStoryteller, #moveCount)
  98.   set oldCount to getAt(lsMoveCounter, 1)
  99.   setAt(lsMoveCounter, 1, oldCount + 1)
  100.   if (getState(oStoryteller, #playerHasPeekUnit) <> 0) and gPeekAlertEnabled then
  101.     if (gScanFinish <> 0) and (the ticks > gScanFinish) then
  102.       setState(oStoryteller, #PKscanStatus, #ReadyForPlayback)
  103.       setState(oStoryteller, #PeekDisplay, #scanStatus)
  104.       set gScanFinish to 0
  105.     end if
  106.     if getState(oStoryteller, #BarOnline) and (getState(oStoryteller, #PeekDisplay) = #none) then
  107.       set showTime to getState(oStoryteller, #hauntDelay)
  108.       if (getAt(lsMoveCounter, 1) > showTime) and (destination <> #LivingRmBarCU2) then
  109.         spawnGhostlyEvent()
  110.         setProp(the lsStateData of oStoryteller, #hauntDelay, [max(0, showTime - 4)])
  111.       end if
  112.     end if
  113.     if getState(oStoryteller, #PeekDisplay) <> #none then
  114.       peekAlert()
  115.       setAt(lsMoveCounter, 1, 0)
  116.     end if
  117.   end if
  118.   return #OK
  119. end
  120.  
  121. on goBack
  122.   global oStoryteller
  123.   goTo(getState(oStoryteller, #previousLocation), #backOff)
  124. end
  125.  
  126. on idle
  127.   global lastCursor, thisCursor, cursorOffset, castCursorList, maxCursor, gClickLoc, oStoryteller, oPuppeteer, gCurrentHotspot, gItemInUse, domainIsReady, gPreloading, gStopTransitions, g16bit, gTransQuality, gFreezeInventory, gSoundPath, gOriginPoint, gMenuBottomY, gInventoryTopY, gGammaLevel, gDeferredTransit
  128.   if gDeferredTransit = #none then
  129.     if domainIsReady then
  130.       cursorOn()
  131.       if getState(oStoryteller, #itemInUse) = #none then
  132.         set thisCursor to #pointer
  133.       else
  134.         set thisCursor to getState(oStoryteller, #itemInUse)
  135.       end if
  136.       set gCurrentHotspot to #none
  137.       if the mouseV < gMenuBottomY then
  138.         if the number of menus = 0 then
  139.           installMenu(14)
  140.           if gTransQuality = #none then
  141.             set the checkMark of menuItem 1 of menu 3 to 1
  142.           end if
  143.           if gTransQuality = #Better then
  144.             set the checkMark of menuItem 2 of menu 3 to 1
  145.           end if
  146.           if gTransQuality = #Best then
  147.             set the checkMark of menuItem 3 of menu 3 to 1
  148.           end if
  149.           set the checkMark of menuItem (8 - the soundLevel) of menu 2 to 1
  150.           if gGammaLevel <> "unknown" then
  151.             set the checkMark of menuItem (8 - gGammaLevel) of menu 4 to 1
  152.           end if
  153.           set thisCursor to #pointer
  154.         end if
  155.       else
  156.         installMenu(0)
  157.       end if
  158.       if not gFreezeInventory then
  159.         if the mouseV > gInventoryTopY then
  160.           if the inventoryStatus of oPuppeteer = #cool then
  161.             set the inventoryStatus of oPuppeteer to #hot
  162.             updateInventory()
  163.             updateStage()
  164.           end if
  165.         else
  166.           if (the inventoryStatus of oPuppeteer = #hot) and (gClickLoc = #none) then
  167.             set the inventoryStatus of oPuppeteer to #cool
  168.             updateInventory()
  169.             updateStage()
  170.           end if
  171.         end if
  172.       end if
  173.       if listp(gClickLoc) then
  174.         set mouseLoc to gClickLoc - gOriginPoint
  175.       else
  176.         set mouseLoc to point(the mouseH, the mouseV) - gOriginPoint
  177.       end if
  178.       repeat with i in the lsLiveHotspots of oPuppeteer
  179.         if inside(mouseLoc, getAt(i, 2)) then
  180.           set myCursor to getAt(i, 1)
  181.           if myCursor = #itemInUse then
  182.             set thisCursor to getState(oStoryteller, #itemInUse)
  183.           else
  184.             set thisCursor to myCursor
  185.           end if
  186.           set gCurrentHotspot to i
  187.           exit repeat
  188.         end if
  189.       end repeat
  190.       if getState(oStoryteller, #itemInUse) = #none then
  191.         if (the mouseCast = getProp(the lsForegroundData of oPuppeteer, #Headgear)) or (the mouseCast = getProp(the lsForegroundData of oPuppeteer, #HeadgearOff)) then
  192.           set thisCursor to #pointer
  193.         end if
  194.       end if
  195.       if (gCurrentHotspot = #none) and (the inventoryStatus of oPuppeteer = #hot) then
  196.         set whichSlot to 1
  197.         repeat with i in [rect(77, 377, 144, 444), rect(147, 377, 214, 444), rect(217, 377, 284, 444), rect(287, 377, 354, 444), rect(357, 377, 424, 444), rect(427, 377, 494, 444), rect(497, 377, 564, 444)]
  198.           if inside(mouseLoc, i) then
  199.             set newItem to getAt(the lsInventory of oPuppeteer, whichSlot)
  200.             if newItem <> #none then
  201.               set gCurrentHotspot to [0, 0, ["useInventory(#" & newItem & ")"]]
  202.             end if
  203.             exit repeat
  204.             next repeat
  205.           end if
  206.           set whichSlot to whichSlot + 1
  207.         end repeat
  208.       end if
  209.       if thisCursor <> lastCursor then
  210.         if the movieRate of sprite 44 = 0 then
  211.           cursorDance(value(lastCursor & "To" & thisCursor))
  212.         else
  213.           cursorDance(0)
  214.         end if
  215.         set lastCursor to thisCursor
  216.       end if
  217.       if getState(oStoryteller, #BT_fragStatus) = #spinningNow then
  218.         refreshAlignmentPuzzle()
  219.       end if
  220.       if getState(oStoryteller, #AMBERVISION) = #on then
  221.         playDomainEntrySound()
  222.         if (the lastEvent > (5 * 60)) and (the castNum of sprite 44 = 7) then
  223.           ripple()
  224.         end if
  225.       end if
  226.     end if
  227.     if listp(gClickLoc) then
  228.       set gClickLoc to #none
  229.     end if
  230.   else
  231.     do(gDeferredTransit)
  232.     if gDeferredTransit contains "waiting" then
  233.       if domainIsReady = 1 then
  234.         if getState(oStoryteller, #currentDomain) = the last word in gDeferredTransit then
  235.           set gDeferredTransit to #none
  236.         end if
  237.       end if
  238.     end if
  239.   end if
  240. end
  241.  
  242. on cursorDance cursorList
  243.   global colorcrsr, thisCursor, YugoCursors, gCPU
  244.   if gCPU <> #PC then
  245.     if not objectp(colorcrsr) then
  246.       cursor(-1)
  247.       set colorcrsr to ColorCursor(mnew)
  248.     end if
  249.   end if
  250.   if not listp(cursorList) then
  251.     if objectp(colorcrsr) then
  252.       colorcrsr(mGetSetCursor, getProp(YugoCursors, thisCursor))
  253.     else
  254.       castCursor(getProp(YugoCursors, thisCursor))
  255.     end if
  256.     exit
  257.   end if
  258.   set flipBook to cursorList
  259.   if objectp(colorcrsr) then
  260.     repeat with flipper = 1 to count(flipBook)
  261.       startTimer()
  262.       colorcrsr(mGetSetCursor, getAt(flipBook, flipper))
  263.       repeat while 2 > the timer
  264.         nothing()
  265.       end repeat
  266.     end repeat
  267.   else
  268.     repeat with flipper = 1 to count(flipBook)
  269.       startTimer()
  270.       castCursor(getAt(flipBook, flipper))
  271.       repeat while 2 > the timer
  272.         nothing()
  273.       end repeat
  274.     end repeat
  275.   end if
  276. end
  277.  
  278. on inState stateVar, whichItem
  279.   global oStoryteller
  280.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  281.   return getPos(statelist, whichItem)
  282. end
  283.  
  284. on trimState stateVar, whichItem
  285.   global oStoryteller
  286.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  287.   set myPos to getPos(statelist, whichItem)
  288.   if myPos then
  289.     deleteAt(statelist, myPos)
  290.   end if
  291. end
  292.  
  293. on addState stateVar, whichItem
  294.   global oStoryteller
  295.   set statelist to getProp(the lsStateData of oStoryteller, stateVar)
  296.   set myPos to getPos(statelist, whichItem)
  297.   if not myPos then
  298.     append(statelist, whichItem)
  299.   end if
  300. end
  301.  
  302. on patchPalette
  303.   global oFixPal
  304.   oFixPal(mPatchIt)
  305. end
  306.  
  307. on forcePalette palName
  308.   global oPuppeteer, gCurrentPalette
  309.   puppetPalette(palName, 60)
  310.   set gCurrentPalette to #changeMe
  311.   patchPalette()
  312. end
  313.  
  314. on loadMultiFrames whichOnes
  315.   global oPuppeteer
  316.   set theFrames to getaProp(the lsMultiFrames of oPuppeteer, whichOnes)
  317.   if listp(theFrames) then
  318.     repeat with i in theFrames
  319.       preLoadCast(i)
  320.     end repeat
  321.   else
  322.     alert("Hey! There's no such list in lsMultiframes!")
  323.   end if
  324. end
  325.  
  326. on purgeMultiframes whichOnes
  327.   global oPuppeteer
  328.   set theFrames to getaProp(the lsMultiFrames of oPuppeteer, whichOnes)
  329.   if listp(theFrames) then
  330.     repeat with i in theFrames
  331.       unLoadCast(i)
  332.     end repeat
  333.   else
  334.     alert("Hey! There's no such list in lsMultiframes!")
  335.   end if
  336. end
  337.  
  338. on gammaFade upOrDown, howFast
  339.   global gCPU
  340.   if gCPU = #PC then
  341.     exit
  342.   end if
  343.   set speedCodes to [#glacial: "4", #slow: "18", #fast: "36", #instant: "100"]
  344.   set mySpeed to getaProp(speedCodes, howFast)
  345.   if voidp(mySpeed) then
  346.     set mySpeed to getProp(speedCodes, #fast)
  347.   end if
  348.   if upOrDown = #down then
  349.     MonitorFade("down", mySpeed)
  350.   else
  351.     updateStage()
  352.     MonitorFade("up", mySpeed)
  353.   end if
  354. end
  355.  
  356. on fadeTest
  357.   gammaFade(#down)
  358.   wait(15)
  359.   gammaFade(#up, #glacial)
  360. end
  361.  
  362. on setColor howManybits
  363.   set the colorDepth to howManybits
  364.   if the colorDepth <> howManybits then
  365.     if howManybits = 16 then
  366.       set the colorDepth to 32
  367.     else
  368.       put "Sorry, Director sez the colorDepth is " & the colorDepth & " bits.."
  369.     end if
  370.   else
  371.   end if
  372. end
  373.  
  374. on waitAsec startSwitch
  375.   global gSecStart
  376.   if voidp(gSecStart) then
  377.     set gSecStart to #idle
  378.   end if
  379.   if startSwitch = #start then
  380.     set gSecStart to the ticks
  381.     return #starting
  382.   else
  383.     set currentTime to the ticks
  384.     if currentTime > (gSecStart + 60) then
  385.       return #finished
  386.       set gSecStart to #idle
  387.     else
  388.       return #waiting
  389.     end if
  390.   end if
  391. end
  392.  
  393. on putDownThePhone
  394.   global oStoryteller, oPuppeteer
  395.   if (getState(oStoryteller, #phoneButtonsPressed) > 0) and inState(#hauntsRemaining, #spookyOperator) then
  396.     setProp(the lsStateData of oStoryteller, #phoneButtonsPressed, [7])
  397.     setState(oStoryteller, #ghostlyPhoneCall, #speaking)
  398.     setProp(the lsStateData of oStoryteller, #phoneButtonsPressed, [0])
  399.   else
  400.     setState(oStoryteller, #playerIsExaminingPhone, 0)
  401.     setState(oStoryteller, #ghostlyPhoneCall, #done)
  402.     setProp(the lsStateData of oStoryteller, #phoneButtonsPressed, [0])
  403.     setTransition(oPuppeteer, #fadeIn)
  404.   end if
  405.   updateDisplay(oPuppeteer)
  406. end
  407.  
  408. on updateInventory
  409.   global oPuppeteer, oStoryteller, gOriginPoint
  410.   set foundationSprite to 3
  411.   set itemV to 410
  412.   set itemH to 110
  413.   set itemInHand to getState(oStoryteller, #itemInUse)
  414.   set lsInventory to the lsInventory of oPuppeteer
  415.   set lsInventoryData to the lsInventoryData of oPuppeteer
  416.   if the inventoryStatus of oPuppeteer = #hot then
  417.     repeat with i = 1 to 7
  418.       set itemName to getAt(lsInventory, i)
  419.       set itemSprite to foundationSprite + i
  420.       if (itemName = #none) or (itemName = itemInHand) then
  421.         set the castNum of sprite itemSprite to 6
  422.         set the loc of sprite itemSprite to point(320, -360) + gOriginPoint
  423.       else
  424.         puppetSprite(itemSprite, 1)
  425.         set the castNum of sprite itemSprite to getAt(getProp(lsInventoryData, itemName), 1)
  426.         set the loc of sprite itemSprite to point(itemH, itemV) + gOriginPoint
  427.       end if
  428.       set itemH to itemH + 70
  429.     end repeat
  430.   else
  431.     repeat with i = 1 to 7
  432.       set itemName to getAt(lsInventory, i)
  433.       set itemSprite to foundationSprite + i
  434.       if (itemName = #none) or (itemName = itemInHand) then
  435.         set the castNum of sprite itemSprite to 6
  436.         set the loc of sprite itemSprite to point(320, -360) + gOriginPoint
  437.       else
  438.         puppetSprite(itemSprite, 1)
  439.         set the castNum of sprite itemSprite to getAt(getProp(lsInventoryData, itemName), 2)
  440.         set the loc of sprite itemSprite to point(itemH, itemV) + gOriginPoint
  441.       end if
  442.       set itemH to itemH + 70
  443.     end repeat
  444.   end if
  445. end
  446.  
  447. on stashClick
  448.   global gClickLoc
  449.   set gClickLoc to point(the mouseH, the mouseV)
  450. end
  451.